package com.study.storm.analytics;

import org.apache.storm.task.OutputCollector;
import org.apache.storm.task.TopologyContext;
import org.apache.storm.topology.OutputFieldsDeclarer;
import org.apache.storm.topology.base.BaseRichBolt;
import org.apache.storm.tuple.Tuple;
import org.apache.storm.tuple.Values;

import java.util.Map;

/**
 * @author Mayjean
 * @Date2020/8/27 21:26
 */
public class UserHistoryBolt extends BaseRichBolt {

    private OutputCollector outputCollector;
    @Override
    public void prepare(Map stormConf, TopologyContext context, OutputCollector collector) {
        outputCollector = collector;
    }

    @Override
    public void execute(Tuple input) {
        String str = input.getString(0);
        String []array = str.split("-");

        outputCollector.emit(new Values(array[0]));
        outputCollector.emit(new Values(array[1]));
    }

    @Override
    public void declareOutputFields(OutputFieldsDeclarer declarer) {

    }
}